<template>
  <div class="app-container">
    <!--中间主体部分-->
    <el-row >
      <el-col v-for="(item,index) in tableList" :key="index" :span="24" >
        <el-card style="width: 90%;margin-left: 5%;margin-top: 35px; border-radius: 20px;" shadow="always"  >

          <div style="display: flex; flex-direction: column;">
            <div style="display: flex;font-size: 40px">
              <el-row style="width: 100%">
                <el-col :span="3">
                  <div style="display: flex;  flex-direction: row; padding-right: 20px;">
                    <el-image :src="cardClass(item.projectCategory)" style="height: 80%;width:80%"></el-image>
                  </div>
                </el-col>
                <el-col :span="20">
                  <div style="display: flex; justify-content: space-between; align-items: center;">
                    <div>项目名称:{{ item.entryName }}</div>
                    <div style="margin-top: 10px;">点单时间:{{ item.registrationTime }}</div>
                  </div>
                  <div style="display: flex; justify-content: space-between; align-items: center;"> <!-- 剩余两个项目，并列显示 -->
                    <div style="display: flex; justify-content: flex-start; align-items: center;"> <!-- 录单员工居右 -->
                      <div style="margin-top: 10px;">手牌号:{{ item.handBrand }}</div>
                    </div>
                    <div style="display: flex; justify-content: flex-end; align-items: center;">
                    </div>
                  </div>
                </el-col>
<!--                <el-col   :span="6">-->
<!--                  <el-button  v-hasPermi="['shop:change:tuidan']" style="float: left" class="add_btn9" type="danger" @click.prevent.stop.native="tuidan(item.id)" plain >退单</el-button>-->
<!--                  &lt;!&ndash;  <el-button  v-if="xiangxilist.consumptionStatus==1" v-hasPermi="['shop:change:tuidan']" style="float: left" class="add_btn9" type="danger" @click.prevent.stop.native="tuidan(item.id)" plain >已退单</el-button>&ndash;&gt;-->
<!--                </el-col>-->
              </el-row>
            </div>
          </div>
        </el-card>

      </el-col>
    </el-row>

    <el-button plain type="primary" round
               style="font-size: 20px;width: 150px;height: 60px;margin-right: 5%;margin-top: 3%;margin-bottom: 3%; float:right" @click="back1()">返回
    </el-button>
    <el-button plain type="primary" round
               style="font-size: 20px;width: 200px;height: 60px;margin-right: 5%;margin-top: 3%;margin-bottom: 3%; float:right" @click="xiayiye()">下一页
    </el-button>
    <el-button plain type="primary" round
               style="font-size: 20px;width: 200px;height: 60px;margin-right: 5%;margin-top: 3%;margin-bottom: 3%; float:right" @click="shangyiye()">上一页
    </el-button>
<!--    <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">-->
<!--      <el-table-column type="selection" width="55" align="center" />-->
<!--      <el-table-column label="id" align="center" prop="id" />-->
<!--      <el-table-column label="登记时间" align="center" prop="registrationTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.registrationTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="点小号" align="center" prop="clickTrumpet" />-->
<!--      <el-table-column label="点大号" align="center" prop="orderLarge" />-->
<!--      <el-table-column label="排活" align="center" prop="rowNumber" />-->
<!--      <el-table-column label="上钟位置" align="center" prop="upclockPosition" />-->
<!--      <el-table-column label="叫钟人签字" align="center" prop="sign" />-->
<!--      <el-table-column label="技师号" align="center" prop="technicianNumber" />-->
<!--      <el-table-column label="上钟时间" align="center" prop="clockTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.clockTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="下钟时间" align="center" prop="nextClockTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.nextClockTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="项目" align="center" prop="entryName" />-->
<!--      <el-table-column label="班次" align="center" prop="sailings" />-->
<!--      <el-table-column label="建表时间" align="center" prop="tableCreationTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.tableCreationTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="客号" align="center" prop="handBrand" />-->
<!--      <el-table-column label="备注" align="center" prop="note" />-->
<!--    </el-table>-->

<!--    <pagination-->
<!--      v-show="total>0"-->
<!--      :total="total"-->
<!--      :page.sync="queryParams.pageNum"-->
<!--      :limit.sync="queryParams.pageSize"-->
<!--      @pagination="getList"-->
<!--    />-->

    <!-- 添加或修改技师上钟情况对话框 -->
  </div>
</template>

<script>
import { listTable, getTable, delTable, addTable, updateTable } from "@/api/module/yzx/Table";

export default {
  name: "Table",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 技师上钟情况表格数据
      tableList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 4,
        registrationTime: null,
        clickTrumpet: null,
        orderLarge: null,
        rowNumber: null,
        upclockPosition: null,
        sign: null,
        technicianNumber: null,
        clockTime: null,
        nextClockTime: null,
        entryName: null,
        sailings: null,
        tableCreationTime: null,
        handBrand: null,
        note: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    xiayiye(){
      var i=Math.floor(this.total/4);
      if(this.queryParams.pageNum==i+1){
        this.$modal.msgError("最后一页");
      }else {
        this.queryParams.pageNum+=1;
        this.getList();
      }
    },
    shangyiye(){
      if(this.queryParams.pageNum==1){
        this.$modal.msgError("第一页");
      }else {
        this.queryParams.pageNum-=1;
        this.getList();
      }
    },
    back1() {
      this.$router.push({path: "/jishi/jingliindex"});
    },
    /** 查询技师上钟情况列表 */
    getList() {
      this.loading = true;
      listTable(this.queryParams).then(response => {
        this.tableList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        registrationTime: null,
        clickTrumpet: null,
        orderLarge: null,
        rowNumber: null,
        upclockPosition: null,
        sign: null,
        technicianNumber: null,
        clockTime: null,
        nextClockTime: null,
        entryName: null,
        sailings: null,
        tableCreationTime: null,
        handBrand: null,
        note: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加技师上钟情况";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTable(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改技师上钟情况";
      });
    },
    cardClass() {
      return  require(`../../../assets/icons/imageicon/34.png`); // 成功状态的颜色类名
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTable(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTable(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除技师上钟情况编号为"' + ids + '"的数据项？').then(function() {
        return delTable(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('project/table/export', {
        ...this.queryParams
      }, `table_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
